﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NGen.Managers.GameObject;
using Microsoft.Xna.Framework.Graphics;
using NGen;
using NGen.Managers.GUI;
using Microsoft.Xna.Framework;
using Psych.Misc;

namespace Psych.GUILayouts
{
    class GUIElementHUD : GUIElement
    {
        Texture2D m_texture;
        Texture2D m_healthTexture;
        Texture2D m_mindTexture;
        Texture2D m_insanityTexture0;
        Texture2D m_insanityTexture1;
        Texture2D m_insanityTexture2;
        Texture2D m_insanityTexture3;
        int health;
        int mind;
        int insanity;

        protected override void _Initialize()
        {
            m_texture = GameEngine.GameContent.Load<Texture2D>("Content\\HUD\\instability_bar");
            m_healthTexture = GameEngine.GameContent.Load<Texture2D>("Content\\HUD\\health_bar_tic");
            m_mindTexture = GameEngine.GameContent.Load<Texture2D>("Content\\HUD\\mental_bar_tic");
            m_insanityTexture0 = GameEngine.GameContent.Load<Texture2D>("Content\\HUD\\instable tic_00");
            m_insanityTexture1 = GameEngine.GameContent.Load<Texture2D>("Content\\HUD\\instable tic_01");
            m_insanityTexture2 = GameEngine.GameContent.Load<Texture2D>("Content\\HUD\\instable tic_02");
            m_insanityTexture3 = GameEngine.GameContent.Load<Texture2D>("Content\\HUD\\instable tic_03");
        }

        protected override void _Draw(GameTime p_gameTime)
        {
            //Outline
            GameEngine.SpriteBatch.Draw(m_texture, new Rectangle(100, 20, 600, 168), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, .20f);
            
            //health
            GameEngine.SpriteBatch.Draw(m_healthTexture, new Rectangle(140, 75, 190 * health / 100, 60), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, .95f);
            
            //mind //check out Vector2 scale for backwards mind bar possibility
            GameEngine.SpriteBatch.Draw(m_mindTexture, new Rectangle(470, 75, 190 * mind / 100, 60), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, .95f);
            
            //insanity
            if (insanity >= 1)
            {
                GameEngine.SpriteBatch.Draw(m_insanityTexture0, new Rectangle(321, 26, 160, 160), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, .5f);
                if (insanity >= 2)
                {
                    GameEngine.SpriteBatch.Draw(m_insanityTexture1, new Rectangle(321, 26, 160, 160), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, .5f);
                    if (insanity >= 3)
                    {
                        GameEngine.SpriteBatch.Draw(m_insanityTexture2, new Rectangle(321, 26, 160, 160), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, .5f);
                        if (insanity >= 4)
                        {
                            GameEngine.SpriteBatch.Draw(m_insanityTexture3, new Rectangle(321, 26, 160, 160), null, Color.White, 0, Vector2.Zero, SpriteEffects.None, .5f);
                        }
                    }
                }
            }


        }

        protected override void Update(Microsoft.Xna.Framework.GameTime p_gameTime)
        {

            health = GameEngine.GetService<GameStats>().Health;
            mind = GameEngine.GetService<GameStats>().Mental;
            insanity = GameEngine.GetService<GameStats>().Insanity;
        }

        protected override void _Cleanup()
        {

        }
    }
    
}
